<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">书单中的书籍</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-2">
                <a href="{:U('Book/index')}?banner_id={$banner_id}" target="_blank">
                    <button class="btn btn-block btn-primary">添加书籍</button>
                </a>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">

                <div class="row">
                    <div class="col-md-12">
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                             id="all_checkbox"></th>

                                        <th style="text-align:center">条形码</th>
                                        <th style="text-align:center">书名</th>
                                        <th style="text-align:center">成色</th>
                                        <th style="text-align:center">作者</th>
                                        <th style="text-align:center">出版社</th>
                                        <th style="text-align:center">书籍包装</th>
                                        <th style="text-align:center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <foreach name="DATA" item="v" key="k">
                                        <tr class="odd gradeX">
                                            <if condition="$v['BOOK_ID']">
                                                <td></td>
                                                <else/>
                                                <td><input type='checkbox' name="checkbox" value="{$v.ID}"></td>
                                            </if>
                                            <td>{$v.ISBN}</td>
                                            <td>{$v.TITLE}</td>
                                            <td>{$v.GG_NAME}</td>
                                            <td>{$v.AUTHOR}</td>
                                            <td>{$v.PRESS}</td>
                                            <td>{$v.PACKING_SPECIFICATION}</td>
                                            <td class="center" style="text-align:center">
                                                <a class="goods-edit text-info" onclick="ycsd('{$v['inventory_id']}',$(this))">从书单中移除</a>
                                            </td>
                                        </tr>
                                    </foreach>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>

                    </div>
                </div>


            </div>
        </div>

    </div>
</div>


<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Admin/Public/js/jquery.datetimepicker.js"></script>
<!-- DataTables JavaScript -->
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->


<script type="text/javascript" src="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.js?v=3"></script>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.css" type="text/css"
      media="screen"/>


<script>

    //    移除书单
    function ycsd(ID, elem) {
        if (confirm("确认移除？")) {
            $.post("{:U('BookList/ycsd')}",
                    {ID: ID},
                    function (data) {
                        if (data == 1) {
                            alert('移除成功');
                            elem.parent().parent().remove();
                        } else {
                            alert('移除失败');
                        }
                    });
        }

    }


    $(document).ready(function () {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
</script>
<script>
    <!--全选择框-->
    $("#all_checkbox").click(function () {
        if ($(this).is(':checked')) {
            $("input[name='checkbox']").prop("checked", "true");
        } else {
            $("input[name='checkbox']").removeAttr("checked", false);

        }
    })
    function checkboxID() {
        var vals = [];
        $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
            vals.push($(this).val());
        });
        if (vals.length <= 0) {
            alert('请选择书籍');
            return 0;
        }
        $.post("{:U('Basket/AddAll')}",
                {IDS: vals},
                function (data) {
                    console.log(data);
                    if (parseInt(data)) {
                        alert('导入书篮子成功');
                        $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
                            $(this).hide();
                        });
                    } else {
                        alert('导入书篮子失败');
                        window.location.reload()
                    }

                });
    }


    function updateSTOCK(ID, elem, top) {
        $.post("{:U('Book/updateSTOCK')}",
                {ID: ID, top: top},
                function (data) {
                    if (parseInt(data) >= 0) {
                        if (top == 1) {
                            elem.next().html(data);
                        } else {
                            elem.prev().html(data);
                        }
                    } else {
                        alert('修改失败,库存不能小于0');
                        window.location.reload()
                    }
                });
    }

    function del(ID, $elem) {
        if (confirm("确认删除？")) {
            $.post("{:U('delete')}",
                    {ID: ID},
                    function (data) {
                        if (parseInt(data) == 1) {
                            $elem.parent().parent().remove();
                            alert('删除成功');
                        } else {
                            alert('删除失败');
                        }
                    });
        }
    }
</script>
</body>

</html>
